Position-independent code is generated by compilers when the virtual address of the instruction is not known at compilation time. Switch tables, typically needed for implementation of switches in C and other similar computer languages, cannot contain actual addresses to which control needs to be passed for each value of the switch variable, but instead contain the addresses relative to some known point (referred to as the reference point or reference address) of the instruction.
A position-independent switch table or switch table, is a block of contiguous entries, each entry representing a number, which is expected to be added to a reference address to obtain the address of the instruction to which control needs to be transferred for a specific value of the variable used in the switch.
Traditional analysis of binary code, as used in the object code insertion technology, tries to detect switches by analyzing instructions and possible values in machine registers. Sometimes the analysis misses switches or finds a switch and its reference point but does not determine the switch table size correctly.
Switch tables usually look like contiguous blocks of data but a switch table can be adjacent to another block of data (e.g., another switch table). An incorrect analysis or misidentification regarding the beginning or end of a switch table, causes multiple switch tables to be identified and subsequently treated as a single switch table. This can result in the introduction of various errors in subsequent processing. Thus, it would be useful to improve the accuracy of the analysis of putative switch tables.